package com.bw.a2301club

import android.annotation.SuppressLint
import android.content.ContentValues.TAG
import android.os.Bundle
import android.renderscript.ScriptGroup.Binding
import android.view.View
import android.widget.ImageView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.alibaba.android.arouter.launcher.ARouter
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.bumptech.glide.request.SingleRequest
import com.bw.lib_common.LoggerUtils
import com.bw.lib_image.GlideApp
import com.bw.lib_net.NetModule
import com.bw.lib_storage.AppMMKV
import com.bw.lib_storage.UserMMKV
import com.bw.lib_storage.db.DBUtils
import com.bw.lib_storage.db.entity.History
import dagger.hilt.android.AndroidEntryPoint
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import java.util.Date
import javax.inject.Inject

//import com.bw.module_main.MainActivity
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
    lateinit var iv: ImageView
    @NetModule.MallRetrofit
    @Inject
    lateinit var retrofit:Retrofit
    @SuppressLint("MissingInflatedId")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        iv = findViewById(R.id.iv)
//        val a = 10/0
    }

    fun toClub(view: View) {
        LoggerUtils.d(TAG, "hilt: "+retrofit)
//        ARouter.getInstance().build("/club/ClubActivity").navigation()
        //anr测试
//        Thread.sleep(10*1000)
//        val a = 10/0
//        MathUtils.chu()

//        AppMMKV.userLogin = true
//        LoggerUtils.d(TAG,AppMMKV.userLogin.toString())
//        UserMMKV.userAgreement = true
//        LoggerUtils.d(TAG, UserMMKV.userAgreement.toString())
//        DBUtils.getDB().historyDao().insert(History(1,"标题1","内容1"))
////            , History(2,"标题2","内容2"))
//        DBUtils.getDB().historyDao().getAllHistory().forEach {
//            LoggerUtils.d(TAG,it.title+it.content)
//        }
        //测试glide
        GlideApp.with(this)
            .load("https://ts1.tc.mm.bing.net/th/id/OIP-C.pQHbME4JQQuYzjqG7nFaYAHaE7?w=264&h=211&c=8&rs=1&qlt=90&o=6&dpr=1.1&pid=3.1&rm=2")
            .transform(CircleCrop())
            .diskCacheStrategy(DiskCacheStrategy.DATA)
            .into(iv)
    }


}